package com.g4m.baselib.interceptor.global;

import com.g4m.baselib.tool.ClientInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 全局接口拦截器
 * Created on 2020-01-01
 * <p>Copyright 2008-2020 snsndk.com</p>
 *
 *
 */
@Component
@Slf4j
@Order(Ordered.HIGHEST_PRECEDENCE)
public class GlobalRequestInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest httpRequest, HttpServletResponse httpResponse, Object handler) {
        ClientInfo.addCrossDomain(httpRequest, httpResponse);
        return true;
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) {

    }
}
